package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class OOSDemo {
    public static void main(String[] args) throws IOException {
        String name = "张三";
        int age =25;
        String gender = "男";
        String[]otherInfo = {"是一名学生","山东省潍坊市的","喜欢读书","喜欢看电影"};
        Student zs = new Student(name,age,gender,otherInfo);
        System.out.println(zs);
        /*
         对象序列化：通过高级流将对象转换为一组组字节，然后通过低级流将对象输出到文件当中去
         */
        FileOutputStream fos = new FileOutputStream("student.obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(zs);
        System.out.println("写出完毕!");
        oos.close();
    }
}
